home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / v10n11.arc / MEM.C < prev    next >
Text File  |  1991-05-10  |  582b  |  33 lines

  1. /* 
  2. MEM.C -- How much memory can we allocate under MS-DOS?
  3.  
  4. Microsoft C: cl -AL mem.c
  5. Turbo C:     tcc -ml mem.c
  6.  
  7. Copyright (c) 1991 Ziff Communications Co.
  8.     PC Magazine * Andrew Schulman
  9. */
  10.  
  11. #include <stdlib.h>
  12. #include <stdio.h>
  13.  
  14. #define SIZE    10240
  15.  
  16. main()
  17. {
  18.     unsigned long bytes = 0;
  19.     char *p;
  20.     
  21.     while (p = malloc(SIZE))
  22.     {
  23.         *p = 'x';
  24.         p[SIZE-1] = 'y';
  25.         bytes += SIZE;
  26.     }
  27.     
  28.     printf("Allocated %lu bytes\n", bytes);
  29.     printf("Press ENTER to release memory...");
  30.     getchar();
  31.     return 0;
  32. }
  33.